<template>
  <div class="login">
    <div class="login_center">
      <p>SN租车后台管理系统</p>

      <el-input
        prefix-icon="el-icon-user-solid"
        class="pw"
        v-model="aname"
      ></el-input>

      <el-input
        prefix-icon="el-icon-s-cooperation"
        v-model="apwd"
        show-password
      ></el-input>

      <el-row type="flex" justify="center">
        <el-button @click="doLogin"  class="btn" size="" type="primary"
          >登录</el-button
        >
      </el-row>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      aname: "",
      apwd: "",
    };
  },
  methods: {
    doLogin() {
      // console.log(this.aname);
      let params = `aname=${this.aname}&apwd=${this.apwd}`;
      this.axios.post("/admin/login", params).then((res) => {
        // console.log(res)
        if (res.data.code == 200) {
          localStorage.setItem("token",res.data.token)
          sessionStorage.setItem("Aname",res.data.data.a_name)
          this.$message({
            message: res.data.msg,
            type: "success",
          });
          
          this.$router.push('managecar')
        } else {
          this.$message.error({
            message: res.data.msg });
        }
      });
    },
  },
};
</script>
<style src="../assets/css/login.css" scoped></style>
<style scoped>
/deep/.el-input__inner {
  margin: 20px 0 ;
  width: 420px ;
  position: relative ;
  left: 50%;
  /* padding-left: 40px; */
  transform: translateX(-50%);
  padding: 0%;
}
/deep/ .el-button {
  text-align: center ;
}
.btn {
  width: 420px ;
}
/deep/ .el-input__icon {
  padding: 0 0 0 15px ;
}
</style>
